﻿@namespace AntDesign
@inherits AntDomComponentBase

<div class="@ClassMapper.Class" @ref="Ref">
    <div class="ant-transfer-list @((FooterTemplate != null || Footer != null)?FooterClass:"")" @onscroll="@(e=>HandleScroll(TransferDirection.Left,e))" style="@Style">
        <div class="ant-transfer-list-header">
            @if (ShowSelectAll)
            {
                <Checkbox Checked="_leftCheckAllState" Indeterminate="_leftCheckAllIndeterminate" Disabled="@Disabled" CheckedChange="@(checkedState => SelectAll(checkedState, TransferDirection.Left))" />
            }
            <span class="ant-transfer-list-header-selected">
                @_leftCountText
            </span>
            @if (Titles[0] != "")
            {
                <span class="ant-transfer-list-header-title">@Titles[0]</span>
            }
        </div>
        <div class="ant-transfer-list-body @(ShowSearch ? "ant-transfer-list-body-with-search" : "")">
            @if (ShowSearch)
            {
                <div class="ant-transfer-list-body-search-wrapper">
                    <div>
                        <Input Class="ant-transfer-list-search" Value="@_leftFilterValue" Placeholder="@Locale.SearchPlaceholder" OnInput="@(e => HandleSearch(e, TransferDirection.Left))" TValue="string"/>
                        <a class="ant-transfer-list-search-action">
                            @if (string.IsNullOrEmpty(_leftFilterValue))
                            {
                                    <span role="img" aria-label="search" class="anticon anticon-search">
                                        <svg viewBox="64 64 896 896" focusable="false" class="" data-icon="search" width="1em" height="1em" fill="currentColor" aria-hidden="true">
                                            <path d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"></path>
                                        </svg>
                                    </span>
                            }
                            else
                            {
                                <span role="img" aria-label="close-circle" class="anticon anticon-close-circle" @onclick="@(() => ClearFilterValueAsync(TransferDirection.Left))">
                                    <svg viewBox="64 64 896 896" focusable="false" class="" data-icon="close-circle" width="1em" height="1em" fill="currentColor" aria-hidden="true">
                                        <path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm165.4 618.2l-66-.3L512 563.4l-99.3 118.4-66.1.3c-4.4 0-8-3.5-8-8 0-1.9.7-3.7 1.9-5.2l130.1-155L340.5 359a8.32 8.32 0 01-1.9-5.2c0-4.4 3.6-8 8-8l66.1.3L512 464.6l99.3-118.4 66-.3c4.4 0 8 3.5 8 8 0 1.9-.7 3.7-1.9 5.2L553.5 514l130 155c1.2 1.5 1.9 3.3 1.9 5.2 0 4.4-3.6 8-8 8z"></path>
                                    </svg>
                                </span>
                            }
                        </a>
                    </div>
                </div>
            }
            @if (!_leftDataSource.Any())
            {
                <div class="ant-transfer-list-body-not-found">
                    <Empty Simple Small/>
                </div>
            }
            else
            {
                <ul class="ant-transfer-list-content ng-star-inserted">
                    @foreach (var item in _leftDataSource)
                    {
                        <li @key="item" class="ant-transfer-list-content-item ng-star-inserted @(item.Disabled || Disabled ? DisabledClass : "")">
                            <Checkbox Label="@item.Key" Checked="_sourceSelectedKeys.Contains(item.Key)" CheckedChange="@(checkedState => SelectItem(checkedState, TransferDirection.Left, item.Key))" Disabled="@(item.Disabled || Disabled)">
                                @if (Render == null)
                                {
                                    @item.Title
                                }
                                else
                                {
                                    var text = Render(item);
                                    @if (text.IsT0)
                                    {
                                        @text.AsT0
                                    }
                                    else
                                    {
                                        @text.AsT1
                                    }
                                }
                            </Checkbox>
                        </li>
                    }
                </ul>
            }
        </div>
        <div class="ant-transfer-list-footer">
            @if (FooterTemplate != null){@FooterTemplate} else {@Footer}
        </div>
    </div>
    <div class="ant-transfer-operation">
        <Button Disabled="@(_leftButtonDisabled||Disabled)" Size="@AntSizeLDSType.Small" Icon="left" Type="@ButtonType.Primary" OnClick="@(e=>MoveItem(e,TransferDirection.Left))">@Operations[0]</Button>
        <Button Disabled="@(_rightButtonDisabled||Disabled)" Size="@AntSizeLDSType.Small" Icon="right" Type="@ButtonType.Primary" OnClick="@(e=>MoveItem(e,TransferDirection.Right))">@Operations[1]</Button>
    </div>
    <div class="ant-transfer-list @((FooterTemplate != null || Footer != null)?FooterClass:"")" @onscroll="@(e => HandleScroll(TransferDirection.Right, e))" style="@Style">
        <div class="ant-transfer-list-header">
            @if (ShowSelectAll)
            {
                <Checkbox Checked="_rightCheckAllState" Indeterminate="_rightCheckAllIndeterminate " Disabled="@Disabled" CheckedChange="@(checkedState => SelectAll(checkedState, TransferDirection.Right))" />
            }
            <span class="ant-transfer-list-header-selected">
                @_rightCountText
            </span>
            @if (Titles[1] != "")
            {
                <span class="ant-transfer-list-header-title">@Titles[1]</span>
            }
        </div>
        <div class="ant-transfer-list-body @(ShowSearch ? "ant-transfer-list-body-with-search" : "")">
            @if (ShowSearch)
            {
                <div class="ant-transfer-list-body-search-wrapper">
                    <div>
                        <Input Class="ant-transfer-list-search" Value="@_rightFilterValue" Placeholder="@Locale.SearchPlaceholder" OnInput="@(e => HandleSearch(e, TransferDirection.Right))" TValue="string"/>
                        <a class="ant-transfer-list-search-action">
                            @if (string.IsNullOrEmpty(_rightFilterValue))
                            {
                                    <span role="img" aria-label="search" class="anticon anticon-search">
                                        <svg viewBox="64 64 896 896" focusable="false" class="" data-icon="search" width="1em" height="1em" fill="currentColor" aria-hidden="true">
                                            <path d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"></path>
                                        </svg>
                                    </span>
                            }
                            else
                            {
                                <span role="img" aria-label="close-circle" class="anticon anticon-close-circle" @onclick="@(() => ClearFilterValueAsync(TransferDirection.Right))">
                                    <svg viewBox="64 64 896 896" focusable="false" class="" data-icon="close-circle" width="1em" height="1em" fill="currentColor" aria-hidden="true">
                                        <path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm165.4 618.2l-66-.3L512 563.4l-99.3 118.4-66.1.3c-4.4 0-8-3.5-8-8 0-1.9.7-3.7 1.9-5.2l130.1-155L340.5 359a8.32 8.32 0 01-1.9-5.2c0-4.4 3.6-8 8-8l66.1.3L512 464.6l99.3-118.4 66-.3c4.4 0 8 3.5 8 8 0 1.9-.7 3.7-1.9 5.2L553.5 514l130 155c1.2 1.5 1.9 3.3 1.9 5.2 0 4.4-3.6 8-8 8z"></path>
                                    </svg>
                                </span>
                            }
                        </a>
                    </div>
                </div>
            }
            @if (!_rightDataSource.Any())
            {
                <div class="ant-transfer-list-body-not-found">
                    <Empty Simple Small/>
                </div>
            }
            else
            {
                <ul class="ant-transfer-list-content">
                    @foreach (var item in _rightDataSource)
                    {
                        <li @key="item" class="ant-transfer-list-content-item @(item.Disabled || Disabled ? DisabledClass : "")">
                            <Checkbox Label="@item.Key" Checked="_targetSelectedKeys.Contains(item.Key)" CheckedChange="@(checkedState => SelectItem(checkedState, TransferDirection.Right, item.Key))" Disabled="@(item.Disabled || Disabled)">
                                @if (Render == null)
                                {
                                    @item.Title
                                }
                                else
                                {
                                    var text = Render(item);
                                    @if (text.IsT0)
                                    {
                                        @text.AsT0
                                    }
                                    else
                                    {
                                        @text.AsT1
                                    }
                                }
                            </Checkbox>
                        </li>
                    }

                </ul>
            }
        </div>
        <div class="ant-transfer-list-footer">
            @if (FooterTemplate != null){@FooterTemplate} else {@Footer}
        </div>
    </div>
</div>